package com.fyakm.daodejing.simple.stockTest.service;


import com.fyakm.daodejing.simple.stockTest.domain.StockHistory;

public class TradingAlgorithm {

    // 买入阈值：涨跌幅超过 5%
    private static final double BUY_THRESHOLD = 5.0;

    // 卖出阈值：涨跌幅低于 -5%
    private static final double SELL_THRESHOLD = -5.0;

    /**
     * 判断是否需要买入或卖出
     *
     * @param history 股票历史数据
     * @return "BUY", "SELL" 或 "HOLD"
     */
    public static String decideAction(StockHistory history) {
        double pctChg = history.getPctChg();
        if (pctChg > BUY_THRESHOLD) {
            return "BUY";
        } else if (pctChg < SELL_THRESHOLD) {
            return "SELL";
        } else {
            return "HOLD";
        }
    }
}